/*
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
 *
 * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
 * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
 *
 * Contributor(s): 
 *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
 *  
 * If you didn't download this code from the following link, you should check
 * if you aren't using an obsolete version: http://www.isqlviewer.com
 */
package org.isqlviewer.ui.wizards.service;

import java.awt.GridBagConstraints;
import java.awt.Insets;

import org.isqlviewer.ui.wizards.Step;
import org.isqlviewer.ui.wizards.Wizard;
import org.isqlviewer.ui.wizards.WizardContext;
import org.isqlviewer.util.LocalMessages;
import org.isqlviewer.util.LoggableObject;

/**
 * @author mkobold
 */
public class ServiceWizard extends LoggableObject implements Wizard {

    static final String BUNDLE_NAME = "org.isqlviewer.ui.wizards.service.ResourceBundle";
    static final String ATTRIBUTE_SERVICE = "org.isqlviewer.service";
    static final String ATTRIBUTE_SERVICE_REFERENCE = "org.isqlviewer.service-reference";
    static final String ATTRIBUTE_FUNCTION = "org.isqlviewer.service-function";
    static final String ATTRIBUTE_PROPERTIES = "org.isqlviewer.service-properties";

    private static final Insets INSETS = new Insets(1, 1, 1, 1);
    private static final GridBagConstraints UI_CONSTRAINT = new GridBagConstraints(0, 0, 0, 0, 0, 0, 0, 0, INSETS, 0, 0);
    private LocalMessages messages = new LocalMessages(BUNDLE_NAME);
    private Step firstStep = null;

    static final String FUNCTION_MODIFY = "modify";
    static final String FUNCTION_DELETE = "delete";
    static final String FUNCTION_CREATE = "new";
    static final String FUNCTION_IMPORT = "import";

    public void init(WizardContext wizardContext) {

        firstStep = new SelectServiceFunctionStep();
        firstStep.init(wizardContext);
    }

    public boolean supportsHome() {

        return false;
    }

    public void cancel(WizardContext wizardContext) {

        info("cancelling new service wizard...");

    }

    public void destroy(WizardContext wizardContext) {

        info("destroying new service wizard...");

    }

    public void finish(WizardContext wizardContext) {

        info("finishing new service wizard...");
    }

    public String getTitle() {

        return messages.getMessage("newservicewizard.main_title");
    }

    public Step firstStep() {

        return firstStep;
    }

    protected static GridBagConstraints constrain(int x, int y, int w, int h, double wx, double wy, int a, int f) {

        UI_CONSTRAINT.gridx = x;
        UI_CONSTRAINT.gridy = y;
        UI_CONSTRAINT.gridwidth = w;
        UI_CONSTRAINT.gridheight = h;
        UI_CONSTRAINT.weightx = wx;
        UI_CONSTRAINT.weighty = wy;
        UI_CONSTRAINT.anchor = a;
        UI_CONSTRAINT.fill = f;
        return UI_CONSTRAINT;
    }
}